package com.service.pay.diamond.controller;

import com.service.pay.diamond.dto.recharge.RechargeDto;
import com.service.pay.diamond.dto.webpay.WebPayNotifyDto;
import com.service.pay.diamond.service.RechargeService;
import com.tool.base.base.BaseDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/recharge")
public class RechargeController {
    @Autowired
    private RechargeService rechargeService;

    @PostMapping("notify")
    public String notify(@RequestBody WebPayNotifyDto notifyDto) {
        rechargeService.handleNotify(notifyDto);
        return "SUCCESS";
    }

    @PostMapping("unifiedOrder")
    public BaseDto<Object> wxUnifiedOrder(@RequestBody RechargeDto rechargeDto) {
        // TODO 校验通知
        return new BaseDto<>(rechargeService.unifiedOrder(rechargeDto));
    }
}
